# This file is part of BlackArch Linux ( https://www.blackarch.org/ ).
# See COPYING for license details.

pkgname=spiderfoot
pkgver=4.0
pkgrel=6
groups=('blackarch' 'blackarch-recon')
pkgdesc='The Open Source Footprinting Tool.'
url='https://github.com/smicallef/spiderfoot'
arch=('any')
license=('GPL2')
depends=('python' 'python-adblockparser' 'python-dnspython' 'python-exifread'
         'python-cherrypy' 'python-mako' 'python-beautifulsoup4' 'python-lxml'
         'python-netaddr' 'python-pysocks' 'python-requests' 'python-ipwhois'
         'python-ipaddr' 'python-phonenumbers' 'python-pygexf' 'python-pypdf2'
         'python-stem' 'python-python-whois' 'python-future' 'python-secure'
         'python-pyopenssl' 'python-python-docx' 'python-python-pptx'
         'python-networkx' 'python-cryptography' 'python-publicsuffixlist'
         'python-cherrypy-cors' 'python-httpagentparser' 'python-openpyxl'
         'python-yaml')
source=("https://github.com/smicallef/$pkgname/archive/v$pkgver.tar.gz")
sha512sums=('a004eccc9f62a47458331375befb1617eaff2f721736a572cddbd6d29f57e38b6f088eb6e5725cc1743a8de34ca7273e4a928cd500275f852048d0bfff90e254')

prepare() {
  cd "$pkgname-$pkgver"

  #sed -i 's|treebuilders._base|treebuilders.base|g' ext/bs4/builder/_html5lib.py
}

build() {
  cd "$pkgname-$pkgver"

  python -m compileall *.py
}

package() {
  cd "$pkgname-$pkgver"

  install -dm 755 "$pkgdir/usr/bin"
  install -dm 755 "$pkgdir/usr/share/$pkgname"

  install -Dm 644 -t "$pkgdir/usr/share/doc/$pkgname/" README.md THANKYOU \
    VERSION
  install -Dm 644 LICENSE "$pkgdir/usr/share/licenses/$pkgname/LICENSE"

  rm README.md LICENSE THANKYOU VERSION

  cp -a * "$pkgdir/usr/share/$pkgname/"

  cat > "$pkgdir/usr/bin/$pkgname" << EOF
#!/bin/sh
cd /usr/share/$pkgname
exec python sf.py "\$@"
EOF

  chmod +x "$pkgdir/usr/bin/$pkgname"

  cat > "$pkgdir/usr/bin/$pkgname-cli" << EOF
#!/bin/sh
cd /usr/share/$pkgname
exec python sfcli.py "\$@"
EOF

  chmod +x "$pkgdir/usr/bin/$pkgname-cli"
}

